import 'package:flutter/material.dart';
import 'package:im_flutter_sdk_example/components/empty_list.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/moment_item.dart';
import 'package:im_flutter_sdk_example/provider/moment_model.dart';
import 'package:provider/provider.dart';

class TimelineList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Consumer<MomentProvider>(
      builder: (BuildContext context, value, Widget child) {
        MomentProvider _moment = Provider.of<MomentProvider>(context);
        if (_moment.data == null) return EmptyList();
        if (_moment.data.data == null) return EmptyList();
        if (_moment.data?.data?.length == 0) return EmptyList();
        return Container(
            padding: EdgeInsets.symmetric(horizontal: 15),
            margin: EdgeInsets.only(top: 10),
            color: Colors.white,
            child: ListView.separated(
              itemBuilder: (BuildContext context, int index) {
                var item = _moment.data.data[index];
                return MomentItemMultiPic(item: item);
              },
              separatorBuilder: (BuildContext context, int index) {
                return Divider();
              },
              itemCount: _moment.data.data.length,
            ));
      },
    );
  }
}
